'''
Created on 14. jan. 2010

@author: per.pedersen
'''


class Calculator(object):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        
    def Add(self, input):
        #handle no input
        if (len(input) == 0): return 0
        
        #extract separator
        if (input[:2] == "//"):
            separator = input[2:input.index("\n")]
            input = input[input.index("\n")+1:]            
            input = input.replace(separator, ",")
            
        #split input
        input = input.replace("\n", ",")
        numbers = input.split(",")
        
        #calculate
        sum = 0
        for a in numbers:
            number = int(a)
            if (number < 0): 
                error = ValueError()
                error.Description = "Negative numbers not allowed"
                raise error
            
            sum += number
        return sum
        